package prehilife;

import java.util.Random;

public class Cave extends StaticCreature {
    private static final int  MAX_RANDOM=100;
    private Random randomCollapse;
    private PrehiWorld world;

    public Cave(PrehiWorld world) {
        this.world = world;
        randomCollapse = new Random();
    }

    private void collapse() {
       int tirage=randomCollapse.nextInt(MAX_RANDOM);
       if(tirage<(MAX_RANDOM/world.collapseChance)){
           world.myGameBoard[super.getPositionX()][super.getPositionY()].remove(this);
           world.setNbCaves(world.getNbCaves()-1);
       }
    }

    @Override
    public void evolve() {
        collapse();
    }

    @Override
    public void unevolve() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}